{extend name="public/base" /}
{block name="head"}
{/block}
{block name="body"}
<div class="page-content" id="page-content">
  <div class="page-title">
    <h5>分类列表</h5>
    <a href="javascript:back()" class="layui-btn layui-btn-small layui-btn-normal back-but">返回</a>
  </div>
	
	<div class="create-content">
		<form class="layui-form" method="post">
			<el-row>
				<el-col :span="12">
					<label class="layui-form-label">上级分类</label>
					<div class="layui-input-block">
						<select name="parent_id">
							<option value="0">最高级</option>
							{volist name="categoryList" id="category"}
								<option value="{$category.id}" <?php if($categoryModel['id'] == $category['id']){echo 'selected';}?>>{$category.category_name}</option>
							{/volist}
						</select>
					</div>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<label class="layui-form-label">分类名字</label>
					<div class="layui-input-block">
						<input type="text" name="category_name" placeholder="请输入分类名字" class="layui-input" value="{$categoryModel.category_name}">
					</div>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="24">
					<div class="layui-form-item">
						<div class="layui-input-block">
							<input type="hidden" name="id" value="{$categoryModel.id}">
							<button class="layui-btn" lay-submit lay-filter="ajaxForm">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</el-col>
			</el-row>
		</form>
	</div>
</div>

<script type="text/javascript">
  layui.use([ 'layer','form'], function(){
    var layer = layui.layer;
    var form = layui.form();
    //全选
		form.on('submit(ajaxForm)', function(data){
			var that = this;
			$(that).attr("disabled","disabled");
			$.ajax({ 
				type: "post", 
				url: data.form.action, 
				data: data.field,
				dataType: 'json', 
				success: function(result){ 
					if(result['code'] == 1){
						layer.msg(result['msg']);
						window.setTimeout(function(){
							window.location.href = document.referrer;
						},800);
					}else{
						layer.msg(result['msg']);
						$(that).removeAttr("disabled");
					}
				} 
			});
			return false;
		});
  });

  fuyun.components(['page'],{
    el:"#page-content",
    data:{
      labelPosition: 'top',
    },
  });
</script>
{/block}



		